define(function(require, exports, module) {
	"require:nomunge,exports:nomunge,module:nomunge";

	var app = require('mokit/app');
	var ProjectListView = require('../views/project-info');
	var commonUtils = require('../common/utils');
	var Project = require('../models/Project');

	/**
	 * 社友录页面控制器
	 */
	return app.controller.create({
		isSetting: true,
		/**
		 * 默认action
		 */
		index: function(context) {
			var self = this;
			Project.getInfo(context.routeData.infoId, function() {
				self.setView(new ProjectListView({
					model: Project
				}));
			});
		},
		//添加收藏
		addCollect: function(context,id) {
			Project.addCollection(id, function(msg){
				if(msg){
					return context.view.alert(context,msg);
				}
				context.view.toast(context,'收藏成功');
			});
		},
		iWantJoin: function(context) {
			var self = this;
			var model = context.view.getNewProjectInfo(context);
			projectModel.theProject.projectName = model.projectName;
			projectModel.theProject.projectInfo = model.projectInfo;
			projectModel.submitProject(function(err) {
				if (err) {
					self.rootView.toast(context, err);
				} else {
					self.go(context, "/project/done", "/project/new");
				}
			});
		},
        //加入项目
         join2project: function(context) {
            context.view.updateModel();
            console.log(Project.joinArgs);
            Project.join2project(function(msg){
            	context.view.alert(context,msg,function(){
            		context.view.closeAddPosition(context);
            	});
            });
        },
	});

});